var t = getApp();

Page({
  data: {
    currentTab: 0,
    commList: "",
    level: 0,
    currentResult: 0,
    commBoo: !0,
    loadingBoo: !0,
    moreBoo: !0,
    requsetBoo: !0,
    commList:{
      good:10,
      middle:20,
      bad:30,
      goodDegree:10
    },
    estimates:[
      {
        phoneMask:'老王',
        estimate: '好好好',
        estimateImages: ["/assets/images/796.png", "/assets/images/796.png", "/assets/images/796.png", "/assets/images/796.png", "/assets/images/796.png",],
        createTime:'2018-10-26',
        itemParam:20
      },
      {
        phoneMask: '老王',
        estimate: '好好好',
        estimateImages: ["/assets/images/796.png", "/assets/images/796.png", "/assets/images/796.png", "/assets/images/796.png", "/assets/images/796.png",],
        createTime: '2018-10-26',
        itemParam: 20
      },
      {
        phoneMask: '老王',
        estimate: '好好好',
        estimateImages: ["/assets/images/796.png", "/assets/images/796.png", "/assets/images/796.png", "/assets/images/796.png", "/assets/images/796.png",],
        createTime: '2018-10-26',
        itemParam: 20
      },
      {
        phoneMask: '老王',
        estimate: '好好好',
        estimateImages: ["/assets/images/796.png", "/assets/images/796.png", "/assets/images/796.png", "/assets/images/796.png", "/assets/images/796.png",],
        createTime: '2018-10-26',
        itemParam: 20
      },
      {
        phoneMask: '老王',
        estimate: '好好好',
        estimateImages: ["/assets/images/796.png", "/assets/images/796.png", "/assets/images/796.png", "/assets/images/796.png", "/assets/images/796.png",],
        createTime: '2018-10-26',
        itemParam: 20
      },
      {
        phoneMask: '老王',
        estimate: '好好好',
        estimateImages: ["/assets/images/796.png", "/assets/images/796.png", "/assets/images/796.png", "/assets/images/796.png", "/assets/images/796.png",],
        createTime: '2018-10-26',
        itemParam: 20
      },
      {
        phoneMask: '老王',
        estimate: '好好好',
        estimateImages: ["/assets/images/796.png", "/assets/images/796.png", "/assets/images/796.png", "/assets/images/796.png", "/assets/images/796.png",],
        createTime: '2018-10-26',
        itemParam: 20
      },
      {
        phoneMask: '老王',
        estimate: '好好好',
        estimateImages: ["/assets/images/796.png", "/assets/images/796.png", "/assets/images/796.png", "/assets/images/796.png", "/assets/images/796.png",],
        createTime: '2018-10-26',
        itemParam: 20
      }
    ]
  },
  onShareAppMessage: function() {
    return t.globalData.share;
  },
  onLoad: function(a) {
    // wx.showLoading({
    //   title: "加载中",
    //   mask: !0
    // });
    // var e = this,
    //   s = a.itemId;
    // this.setData({
    //   itemId: s
    // }), wx.request({
    //   url: t.globalData.httpOne + "mall/estimate/list/" + this.data.itemId + "/" + e.data.currentResult,
    //   data: {
    //     level: 0
    //   },
    //   success: function(a) {
    //     if (console.log(a), 200 == a.data.code) {
    //       var s = a.data.data.estimates;
    //       null != s ? s.forEach(function(a, e) {
    //         a.createTime = t.toDate(a.createTime);
    //       }) : e.setData({
    //         commBoo: !1
    //       }), e.setData({
    //         commList: a.data.data,
    //         estimates: s,
    //         currentResult: a.data.data.pageInfo.nextResult,
    //         total: a.data.data.total
    //       });
    //     }
    //   },
    //   fail: function() {
    //     wx.showToast({
    //       title: "系统繁忙，请稍后重试",
    //       icon: "none",
    //       duration: 2e3
    //     });
    //   },
    //   complete: function() {
    //     wx.hideLoading();
    //   }
    // });
  },
  swichNav: function(a) {
    wx.showLoading({
      title: "加载中...",
      mask: !0
    });
    var e = this;
    if (this.data.currentTab != a.target.dataset.current) {
      var s = a.target.dataset.current;
      this.setData({
        currentTab: a.target.dataset.current,
        level: s,
        // estimates: "",
        currentResult: 0,
        commBoo: !0,
        moreBoo: !0
      }), wx.request({
        url: t.globalData.httpOne + "mall/estimate/list/" + e.data.itemId + "/" + e.data.currentResult,
        data: {
          level: e.data.level
        },
        success: function(a) {
          if (200 == a.data.code) {
            var s = a.data.data.estimates;
            null != s ? s.forEach(function(a, e) {
              a.createTime = t.toDate(a.createTime), a.star = t.starFun(a.star);
            }) : e.setData({
              commBoo: !1
            }), e.setData({
              commList: a.data.data,
              // estimates: s,
              currentResult: a.data.data.pageInfo.nextResult
            });
          }
        },
        fail: function() {
          wx.showToas({
            title: "系统繁忙，请稍后重试",
            icon: "none",
            duration: 2e3
          });
        },
        complete: function() {
          wx.hideLoading();
        }
      });
    }
  },
  moreOrder: function() {
    if (this.data.requsetBoo && this.data.moreBoo) {
      var a = this,
        e = this.data.currentResult,
        s = this.data.estimates;
      e >= this.data.total ? this.setData({
        moreBoo: !1
      }) : (this.setData({
        loadingBoo: !1
      }), wx.request({
        url: t.globalData.httpOne + "mall/estimate/list/" + a.data.itemId + "/" + a.data.currentResult,
        data: {
          level: a.data.level
        },
        success: function(e) {
          if (200 == e.data.code) {
            var o = e.data.data.estimates;
            null != o ? o.forEach(function(a, e) {
              a.createTime = t.toDate(a.createTime), a.star = t.starFun(a.star), s.push(a);
            }) : a.setData({
              moreBoo: !1
            }), a.setData({
              commList: e.data.data,
              estimates: s,
              currentResult: e.data.data.pageInfo.nextResult,
              loadingBoo: !0,
              requsetBoo: !0
            });
          }
        },
        fail: function() {
          wx.showToast({
            title: "系统繁忙，请稍后重试",
            icon: "none",
            duration: 2e3
          });
        }
      }), this.setData({
        requsetBoo: !1
      }));
    }
  },
  previewImage: function(t) {
    var a = t.target.dataset.targeturl,
      e = [];
    this.data.estimates.forEach(function(t) {
      t.estimateImages && t.estimateImages.forEach(function(t) {
        e.push(t);
      });
    }), wx.previewImage({
      current: a,
      urls: e,
      success: function(t) {}
    });
  }
});